﻿<?php
session_start();

$User = $_POST['textMailUsuario'];
$Pass = $_POST['textPasswordUsuario'];

if($User == "" || $Pass == ""){
	echo"<script language='JavaScript'>
                alert('INGRESE USUARIO Y/O CONTRASEÑA');
                </script>";
}
else{
	
      $link = mysql_connect("localhost","root","")or die("Problemas en la conexion");
      mysql_select_db("personalizatuweb", $link);

      $result = mysql_query("SELECT * FROM usuarios where EMAIL='".$User."' and PASSWORD='".$Pass."'", $link) or die("Problemas en el la consulta SELECT:".mysql_error());
  
      $CantResult = mysql_num_rows($result);
	  
	  if($CantResult > 0){
		  while( $row = mysql_fetch_array($result)){
	   	  $_SESSION['CODIGO_USUARIO'] = $row['ID_USUARIO'];
		  header ("Location: User");}
	  }
	  else{
				
		
		echo"<script language='JavaScript'>
                alert('USUARIO NO VALIDO');
                </script>";
		header ("Location: index.html");				
		}
	mysql_close($link);
	}


?>